]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot-ui: Add two key bindings from g-s-d
authorIvan Molodetskikh <yalterz@gmail.com>
Sat, 15 Jan 2022 16:06:49 +0000 (19:06 +0300)
committerMarge Bot <marge-bot@gnome.org>
Sat, 12 Feb 2022 12:13:22 +0000 (12:13 +0000)
These two are moving into gnome-shell to unify screenshot handling and
allow for same-frame capturing.

While we're at it, move the keybindings .xml file from g-c-c here
because it belongs to gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2107>

data/50-gnome-shell-screenshots.xml [new file with mode: 0644]
data/meson.build
data/org.gnome.shell.gschema.xml.in
js/ui/screenshot.js
po/POTFILES.in

diff --git a/data/50-gnome-shell-screenshots.xml b/data/50-gnome-shell-screenshots.xml
new file mode 100644 (file)
index 0000000..d99f60b
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<KeyListEntries schema="org.gnome.shell.keybindings"
+                group="system"
+                name="Screenshots"
+                wm_name="GNOME Shell"
+                package="gnome-shell">
+
+    <KeyListEntry name="show-screenshot-ui"
+                  description="Take a screenshot interactively"/>
+
+    <KeyListEntry name="screenshot"
+                  description="Take a screenshot"/>
+
+    <KeyListEntry name="screenshot-window"
+                  description="Take a screenshot of a window"/>
+
+</KeyListEntries>
\ No newline at end of file
index 311a2b8f91140d57edea4947c4975160502b1db4..30d4917d8e9320ea603dd85dfd30ddcc96d75b4e 100644 (file)
@@ -79,6 +79,7 @@ configure_file(
 
 keybinding_files = [
   '50-gnome-shell-launchers.xml',
+  '50-gnome-shell-screenshots.xml',
   '50-gnome-shell-system.xml',
 ]
 
index 1dadb13c280bf0a555c2335765cabaa3d398ae77..e686d2203d1f72e3c01ba3ea062e22baeefece50 100644 (file)
     </key>
     <key name="show-screenshot-ui" type="as">
       <default>["Print"]</default>
-      <summary>Show screenshot UI</summary>
+      <summary>Take a screenshot interactively</summary>
+    </key>
+    <key name="screenshot-window" type="as">
+      <default>["&lt;Alt&gt;Print"]</default>
+      <summary>Take a screenshot of a window</summary>
+    </key>
+    <key name="screenshot" type="as">
+      <default>["&lt;Shift&gt;Print"]</default>
+      <summary>Take a screenshot</summary>
     </key>
   </schema>
 
index 2b70d1d0cfcedd99d15f769139fc78a8cfe967ad..cc81490c9849bd5fcf1099bc66d136a2820c4ed7 100644 (file)
@@ -1288,6 +1288,42 @@ var ScreenshotUI = GObject.registerClass({
             uiModes,
             showScreenshotUI
         );
+
+        Main.wm.addKeybinding(
+            'screenshot-window',
+            new Gio.Settings({ schema_id: 'org.gnome.shell.keybindings' }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT | Meta.KeyBindingFlags.PER_WINDOW,
+            uiModes,
+            async (_display, window, _binding) => {
+                try {
+                    const actor = window.get_compositor_private();
+                    const content = actor.paint_to_content(null);
+                    const texture = content.get_texture();
+
+                    await captureScreenshot(texture, null, 1, null);
+                } catch (e) {
+                    logError(e, 'Error capturing screenshot');
+                }
+            }
+        );
+
+        Main.wm.addKeybinding(
+            'screenshot',
+            new Gio.Settings({ schema_id: 'org.gnome.shell.keybindings' }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            uiModes,
+            async () => {
+                try {
+                    const shooter = new Shell.Screenshot();
+                    const [content] = await shooter.to_content();
+                    const texture = content.get_texture();
+
+                    await captureScreenshot(texture, null, 1, null);
+                } catch (e) {
+                    logError(e, 'Error capturing screenshot');
+                }
+            }
+        );
     }
 
     _refreshButtonLayout() {
index aafc3e345048a590f433d8641158267917f13438..2f6bd0ae76aa2605afd66a50b195f674c8e228a5 100644 (file)
@@ -1,6 +1,7 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 data/50-gnome-shell-launchers.xml
+data/50-gnome-shell-screenshots.xml
 data/50-gnome-shell-system.xml
 data/org.gnome.Shell.desktop.in.in
 data/org.gnome.shell.gschema.xml.in